import { Component, OnInit } from '@angular/core';
import {CustomLoginForm} from "../../../../to/CustomLoginForm";
import {NzModalRef} from "ng-zorro-antd/modal";
import {AlertService} from "../../../../services/alert.service";
import {CustomService} from "../../../../services/custom.service";

@Component({
  selector: 'app-customerlogin',
  templateUrl: './customerlogin.component.html',
  styleUrls: ['./customerlogin.component.css']
})
export class CustomerloginComponent implements OnInit {
  customloginform:CustomLoginForm
  constructor(private modal: NzModalRef
              ,private alertservice:AlertService
              ,private customservice:CustomService
  ) {
    this.customloginform=new CustomLoginForm();
  }

  ngOnInit(): void {


  }



  login(){
    this.customservice.getCustomToken(this.customloginform)
      .then((data:any)=>{
        //console.dir(data);
        if(data.msg=='ok'){
          this.customservice.userid=data.userid;
          this.customservice.token=data.token;
          this.modal.close('ok');
        }
        else {
         this.modal.close('error');
        }


      })
  }







}
